package com.idealighter.game.games.blackjack.struct;

import com.idealighter.utils.check.EmptyUtil;

import java.util.List;

public class BlackjackCardsTypeWeight {

  /**
   * 获取牌型权重 .
   *
   * @author abin
   * @date 2018年3月31日 上午11:49:45
   * @param cardsTypeAndPoint 牌组与点数.
   * @return 获取牌型权重.
   */
  public static int getWeight(BlackjackCardsTypeAndPoint cardsTypeAndPoint) {
    int weight = 0;
    switch (cardsTypeAndPoint.getCardsType()) {
      case BUST:
        weight = 30;
        break;
      case NORMAL:
        weight = 10;
        weight += (21 - cardsTypeAndPoint.getPoint()) * 2;
        break;
      case FIVE_DRAGON:
        weight = 2;
        break;
      case BLACK_JACK:
        weight = 1;
        break;


      default:
        break;
    }
    return weight;
  }

  /**
   * 获取牌型总权重 .
   *
   * @author abin
   * @date 2018年3月31日 上午11:51:38
   * @param cardsTypeAndPoints 牌组类型与点数数组.
   * @return 总权重.
   */
  public static int totalWeight(List<BlackjackCardsTypeAndPoint> cardsTypeAndPoints) {
    int totaWeight = 1;
    if (EmptyUtil.listIsNotEmpty(cardsTypeAndPoints)) {
      for (BlackjackCardsTypeAndPoint cardsTypeAndPoint : cardsTypeAndPoints) {
        totaWeight += getWeight(cardsTypeAndPoint);
      }
    }

    return totaWeight;
  }
}
